<?php

/**
 * PHP Captcha Form Validator
 *
 * @package    sfPHPCaptchaPlugin
 * @subpackage form
 * @author     Sven Wappler <info@wapplersystems.de>
 */
class sfValidatorFormInputRang extends sfValidatorBase  {

    protected function configure($options = array(), $messages = array()){
        parent::configure($options , $messages);
        $this->addOption('require_both' , false);
    }

    protected function doClean($value) {

        
        
        
       /*
        if( !empty($value['is_root']) ){
        return null;
        }*/

        //var_dump($value);exit;
        if($this->getOption('require_both') && is_array($value) && count($value) > 0 && (   !empty($value['to']) || !empty($value['from'])   )){
            foreach ($value as $v){
                if(empty($v)){
                    throw new sfValidatorError($this, 'invalid');
                }
            }
        }

        //echo "<pre>";var_dump($value);exit;
        if(empty($value['from']) && empty($value['to'])){
            return null;
        }
        if(empty($value['from'])){
            unset($value['from']);
        }
        if(empty($value['to'])){
            unset($value['to']);
        }
        
        
        return $value;


    }

}

